package io.github.jesse205.dragdrop.pro.ui.home

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import io.github.jesse205.dragdrop.pro.databinding.FragmentHomeBinding
import io.github.jesse205.dragdrop.pro.extensions.setupToolbar
import io.github.jesse205.dragdrop.pro.extensions.thisActivity
import io.github.jesse205.dragdrop.pro.ui.contents.ContentsActivity

class HomeFragment : Fragment() {

    private var _binding: FragmentHomeBinding? = null

    private val binding get() = _binding!!
    private val model by viewModels<HomeViewModel>()

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentHomeBinding.inflate(inflater, container, false)
        initViews()
        return binding.root
    }

    private fun initViews(){
        setupToolbar(binding.toolbar)
        binding.contentsLayout.setOnClickListener {
            val intent = Intent(thisActivity, ContentsActivity::class.java)
            startActivity(intent)
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}